package com.hqhy.like.stock.controller;

import com.hqhy.like.common.pojo.vo.PageData;
import com.hqhy.like.common.web.JsonResult;
import com.hqhy.like.stock.pojo.vo.TotalListItemVO;
import com.hqhy.like.stock.service.ITotalService;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.constraints.Range;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 饭店-库存-总量Controller
 */

@Slf4j
@RestController
@RequestMapping("/stock/total")
public class TotalController {

    @Autowired
    private ITotalService totalService;

    /**
     * 查询饭店-库存-总量列表
     */
    @GetMapping("")
    public JsonResult list(@Range(min = 1, message = "请提交有效的页码值！") Integer page,Integer size) {
        log.debug("开始处理【查询库存总量列表】的请求，页码：{}", page);
        Integer pageNum = page == null ? 1 : page;
        PageData<TotalListItemVO> pageData = totalService.list(pageNum,size);
        return JsonResult.ok(pageData);
    }

    /**
     * 修改库存总量的备注
     */
    @PostMapping("/update")
    public JsonResult updateById(Long id, String notes){
        log.debug("开始处理【修改库存总量的备注】的请求，id：{},备注:{}",id,notes);
        totalService.update(id,notes);
        return JsonResult.ok();
    }

}

